package com.zty.xiaomiadmin.server.Dao;

import com.zty.xiaomiadmin.server.Entity.ServiceOrder.ServiceOrder;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface ServiceOrderMapper {
    @Select("select id,orderNo,good_id,service_id,insurance_name,refund_amount,service_reason,service_way," +
            "express,returnAddress,instructions,instructions_img,status,store_reply,good_status from service_order" +
            " where status = #{status} and store_id = #{store_id} limit #{pageIndex}, #{pageSize}")
    List<ServiceOrder> getServiceOrderByStatusAndStoreId(int pageIndex,int pageSize,int status,int store_id);

    @Select("select count(id) from serviceOrder where status = #{status} and store_id = #{store_id}")
    int countServiceOrderByStatusAndStoreId(int status,int store_id);

    @Select("select id,orderNo,good_id,service_id,insurance_name,refund_amount,service_reason,service_way," +
            "express,returnAddress,instructions,instructions_img,status,store_reply,good_status from service_order" +
            " where store_id = #{store_id} limit #{pageIndex}, #{pageSize}")
    List<ServiceOrder> getServiceOrderByStoreId(int pageIndex,int pageSize,int store_id);

    @Select("select count(id) from serviceOrder where store_id = #{store_id}")
    int countServiceOrderByStoreId(int store_id);

    @Select("select id,orderNo,good_id,service_id,insurance_name,refund_amount,service_reason,service_way," +
            "express,returnAddress,instructions,instructions_img,status,store_reply,good_status from service_order " +
            "limit #{pageIndex}, #{pageSize}")
    List<ServiceOrder> getServiceOrder(int pageIndex,int pageSize);

    @Update("update service_order set status = #{status}, store_reply = #{store_reply} where id = #{id}")
    int updateServiceOrderById(int id, int status, String store_reply);


}
